package contest1611;

import java.util.Arrays;
import java.util.Scanner;

public class K {
    static class Task implements Comparable<Task> {
        int start, end;

        @Override
        public int compareTo(Task that) {
            return this.start - that.start;
        }

        public Task(int start, int end) {
            this.start = start;
            this.end = end;
        }
    }

    public static void main(String[] args) {

        Task[] tasks = new Task[cin.nextInt()];
        boolean[] used = new boolean[tasks.length];
        for (int i = 0; i < tasks.length; i++) {
            tasks[i] = new Task(cin.nextInt(), cin.nextInt());
        }
        Arrays.sort(tasks);
        int rooms = 0, cnt = 0;
        while (cnt < tasks.length) {
            ++rooms;
            int end = 0;
            for (int i = 0; i < tasks.length; i++) {
                if (used[i]) continue;
                if (tasks[i].start >= end) {
                    ++cnt;
                    end = tasks[i].end;
                    used[i] = true;
                }
            }
        }
        System.out.println(rooms);

        cin.close();
    }

    static Scanner cin = new Scanner(System.in);
}
